package com.ccp.dev.workflow.model;

import com.ccp.dev.core.basic.model.BaseModel;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;

/**
 * 对象功能:流程定义节点用户
 * @author jiayueqiao
 */
@XmlRootElement(name = "bpmNodeUser")
@XmlAccessorType(XmlAccessType.NONE)
public class BpmNodeUser extends BaseModel<BpmNodeUser> {
	/**
	 * 发起人=0
	 */
	public static final short ASSIGN_TYPE_START_USER = 0;
	/**
	 * 用户=1
	 */
	public static final String ASSIGN_TYPE_USER = "users";
	/**
	 * 角色=2
	 */
	public static final String ASSIGN_TYPE_ROLE = "role";
	/**
	 * 组织=3
	 */
	public static final String ASSIGN_TYPE_ORG = "org";
	/**
	 * 组织负责人=4
	 */
	public static final String ASSIGN_TYPE_ORG_CHARGE = "orgCharge";
	/**
	 * 岗位=5
	 */
	public static final String ASSIGN_TYPE_POS = "pos";
	/**
	 * 上下级=6
	 */
	public static final String ASSIGN_TYPE_UP_LOW = "upLow";
	/**
	 * 用户属性=7
	 */
	public static final String ASSIGN_TYPE_USER_ATTR = "userAttr";
	/**
	 * 组织属性=8
	 */
	public static final String ASSIGN_TYPE_ORG_ATTR = "orgAttr";
	/**
	 * 本部门=9 即与发起人相同部门
	 */
	public static final short ASSIGN_TYPE_SAME_DEP = 9;
	/**
	 * 跟某个节相同执行人
	 */
	public static final String ASSIGN_TYPE_SAME_NODE = "sameNode";
	/**
	 * 发起人的直属领导
	 */
	public static final short ASSIGN_TYPE_DIRECT_LED = 11;
	/**
	 * 脚本
	 */
	public static final short ASSIGN_TYPE_SCRIPT = 12;
	/**
	 * 上个任务执行人的直属领导(组织)
	 */
	public static final short ASSIGN_TYPE_PREUSER_ORG_LEADER=13;
	/**
	 * 发起人的领导
	 */
	public static final short ASSIGN_TYPE_STARTUSER_LEADER=14;
	/**
	 * 上个任务执行人的领导
	 */
	public static final short ASSIGN_TYPE_PREVUSER_LEADER=15;
	
	/**
	 * 执行者部门的上级类型部门的负责人
	 */
	public static final short ASSIGN_TYPE_PREVTYPEUSER_LEADER=16;
	

	

	/**
	 * 运算类型为 or
	 */
	public static final short COMP_TYPE_OR = 0;
	/**
	 * 运算类型为 and
	 */
	public static final short COMP_TYPE_AND = 1;
	/**
	 * 运算类型为 exclude
	 */
	public static final short COMP_TYPE_EXCLUDE = 2;

	
	/**
	 * 归档触发的任务节点id
	 */
	public static final String NODE_ID_SYS_PROCESS_END_TASK="SYS_PROCESS_END_TASK";

	/**
	 * nodeUserId
	 */
	@XmlAttribute
	protected String nodeUserId;

	/**
	 * 分配的类型
	 */
	@XmlAttribute
	protected String assignType="";

	/**
	 * 分配的id字符串，例id1,id2
	 */
	@XmlAttribute
	protected String cmpIds;

	/**
	 *分配的名称字符串，例name1,name2
	 */
	@XmlAttribute
	protected String cmpNames;

	/**
	 * 运算类型（与、或、非）
	 */
	@XmlAttribute
	protected Short compType;

	/**
	 * sn
	 */
	@XmlAttribute
	protected Integer sn;

	/**
	 * 条件ID
	 */
	@XmlAttribute
	protected String conditionId;

	/**
	 * 是否抽取用户 0:不抽取 1:抽取
	 */
	@XmlAttribute
	protected Short extractUser;

	public void setNodeUserId(String nodeUserId) {
		this.nodeUserId = nodeUserId;
	}
	public String getNodeUserId() {
		return nodeUserId;
	}

	public void setAssignType(String assignType) {
		this.assignType = assignType;
	}

	public String getAssignType() {
		return assignType;
	}
	public String getCmpIds() {
		return cmpIds;
	}

	public void setCmpIds(String cmpIds) {
		this.cmpIds = cmpIds;
	}

	public String getCmpNames() {
		return cmpNames;
	}

	public void setCmpNames(String cmpNames) {
		this.cmpNames = cmpNames;
	}

	public Short getCompType() {
		return compType;
	}

	public void setCompType(Short compType) {
		this.compType = compType;
	}

	public Integer getSn() {
		return sn;
	}

	public void setSn(Integer sn) {
		this.sn = sn;
	}

	public String getConditionId() {
		return conditionId;
	}

	public void setConditionId(String conditionId) {
		this.conditionId = conditionId;
	}
	public Short getExtractUser() {
		return extractUser;
	}

	public void setExtractUser(Short extractUser) {
		this.extractUser = extractUser;
	}

	/**
	 * @see Object#equals(Object)
	 */
	@Override
	public boolean equals(Object object) {
		if (!(object instanceof BpmNodeUser)) {
			return false;
		}
		BpmNodeUser rhs = (BpmNodeUser) object;
		return new EqualsBuilder().append(this.nodeUserId, rhs.nodeUserId).
				append(this.cmpIds, rhs.cmpIds)
				.append(this.conditionId, rhs.conditionId).append(this.cmpNames, rhs.cmpNames).isEquals();
	}

	/**
	 * @see Object#hashCode()
	 */
	@Override
	public int hashCode() {
		return new HashCodeBuilder(-82280557, -700257973).append(this.nodeUserId).append(this.assignType)
				.append(this.cmpIds)	.append(this.conditionId).append(this.cmpNames).toHashCode();
	}

	/**
	 * @see Object#toString()
	 */
	@Override
	public String toString() {
		return new ToStringBuilder(this).append("nodeUserId", this.nodeUserId)
				.append("assignType", this.assignType).append("cmpIds", this.cmpIds).append("cmpNames", this.cmpNames)				
					.append("conditionId",this.conditionId).toString();
	}

	@Override
	public Object clone() {
		BpmNodeUser obj = null;
		try {
			obj = (BpmNodeUser) super.clone();
		} catch (CloneNotSupportedException e) {
			e.printStackTrace();
		}
		return obj;
	}

}